package com.dingding.gmall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @author liudingding
 * @ClassName MyRedissonConfig
 * @description
 * @date 2021/6/13 1:43 下午
 */

@Configuration
public class MyRedissonConfig {

    /**
     * 所有对 redisson 的使用都是通过 RedissonClient
     * @return
     * @throws IOException
     */
    @Bean(destroyMethod="shutdown")
    RedissonClient redisson() throws IOException {
        //1、创建配置对象
        Config config = new Config();
        //让 RedissonClient 客户端 连接 Redis 服务
        config.useSingleServer().setAddress("redis://127.0.0.1:6379");
        return Redisson.create(config);
    }
}
